package flc.ast;

import android.graphics.Color;
import android.view.View;

import androidx.annotation.NonNull;

import java.util.ArrayList;
import java.util.List;

import flc.ast.databinding.ActivityHomeBinding;
import flc.ast.fragment.BingeWatchFragment;
import flc.ast.fragment.HomeFragment;
import flc.ast.fragment.MyFragment;
import flc.ast.fragment.PlayerFragment;
import stark.common.basic.base.BaseNoModelActivity;
import stark.common.basic.base.BaseTabFragmentHomeActivity;
import stark.common.basic.base.DefExitAppDialog;
import stark.common.basic.event.EventStatConstant;
import stark.common.basic.event.EventStatProxy;
import stark.common.basic.utils.StatusBarUtils;

public class HomeActivity extends BaseTabFragmentHomeActivity<ActivityHomeBinding> implements View.OnClickListener {

    @Override
    protected int getPageType() {
        return EventStatConstant.PAGE_TAB_HOME;
    }

    @Override
    protected void initView() {
        super.initView();
        EventStatProxy.getInstance().statLaunch(this);
        mDataBinding.llHomeBottom.setOnClickListener(null);
    }

    @Override
    protected void onHandleStatusBar() {
        super.onHandleStatusBar();
        //设置状态栏字体颜色
        StatusBarUtils.setSystemStatusTextColor(true, this);
    }

    @NonNull
    @Override
    protected List<BaseTabFragmentHomeActivity<ActivityHomeBinding>.FragmentViewBinder> getFragmentViewBinders() {
        List<FragmentViewBinder> listFragment = new ArrayList<>();
        listFragment.add(new FragmentViewBinder(HomeFragment.class, R.id.llHome));
        listFragment.add(new FragmentViewBinder(BingeWatchFragment.class, R.id.llBingeWatch));
        listFragment.add(new FragmentViewBinder(PlayerFragment.class, R.id.llPlayer));
        listFragment.add(new FragmentViewBinder(MyFragment.class, R.id.llMy));
        return listFragment;
    }

    @Override
    protected void onFragmentViewClick(View view) {
        clearSelection();
        switch (view.getId()) {
            case R.id.llHome:
                mDataBinding.ivHome.setImageResource(R.drawable.ystj_tab);
                mDataBinding.tvHome.setTextColor(Color.parseColor("#333333"));
                break;
            case R.id.llBingeWatch:
                mDataBinding.ivBingeWatch.setImageResource(R.drawable.zj7);
                mDataBinding.tvBingeWatch.setTextColor(Color.parseColor("#333333"));
                break;
            case R.id.llPlayer:
                mDataBinding.ivPlayer.setImageResource(R.drawable.bfq_tab);
                mDataBinding.tvPlayer.setTextColor(Color.parseColor("#333333"));
                break;
            case R.id.llMy:
                mDataBinding.ivMy.setImageResource(R.drawable.wd_tab);
                mDataBinding.tvMy.setTextColor(Color.parseColor("#333333"));
                break;
        }
    }

    @Override
    protected int getFragmentContainerId() {
        return R.id.flHome;
    }

    @Override
    protected int onCreate() {
        return R.layout.activity_home;
    }

    private void clearSelection() {
        mDataBinding.ivHome.setImageResource(R.drawable.ystjw);
        mDataBinding.tvHome.setTextColor(Color.parseColor("#BEBEBE"));
        mDataBinding.ivBingeWatch.setImageResource(R.drawable.zjw);
        mDataBinding.tvBingeWatch.setTextColor(Color.parseColor("#BEBEBE"));
        mDataBinding.ivPlayer.setImageResource(R.drawable.bfqw);
        mDataBinding.tvPlayer.setTextColor(Color.parseColor("#BEBEBE"));
        mDataBinding.ivMy.setImageResource(R.drawable.wdw);
        mDataBinding.tvMy.setTextColor(Color.parseColor("#BEBEBE"));
    }

}